<div class="exportDatabase content-margin">
<div class="panel">
    <div class="panel-body">
        <form data-bind="submit: startExport">
            <h3>Export your database to a .ravendbdump file</h3>
            <div class="row">
                <div class="col-sm-12 col-lg-6">
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon">Destination File Name:</div>
                            <input class="form-control" data-bind="textInput: model.exportFileName"/>
                        </div>
                    </div>
                </div>
            </div>
            <div data-bind="with: model">
                <div class="row">
                    <div class="col-lg-3">
                        <h4>Documents and Extensions:</h4>
                        <div class="margin-left">
                            <div class="toggle">
                                <input id="toggleDocuments" type="checkbox" data-bind="checked: includeDocuments" />
                                <label for="toggleDocuments">Include Documents</label>
                            </div>
                            <div class="margin-left">
                                <div class="toggle">
                                    <input id="toggleAttachments" type="checkbox"
                                           data-bind="checked: includeAttachments" />
                                    <label for="toggleAttachments">Include Attachments</label>
                                </div>
                                <div class="toggle">
                                    <input id="toggleCounters" type="checkbox"
                                           data-bind="checked: includeCounters" />
                                    <label for="toggleCounters">Include Counters</label>
                                </div>
                                <div class="toggle">
                                    <input id="toggleTimeSeries" type="checkbox"
                                           data-bind="checked: includeTimeSeries" />
                                    <label for="toggleTimeSeries">Include Time Series</label>
                                </div>
                            <div class="toggle">
                                <input id="toggleRevisions" type="checkbox" data-bind="checked: includeRevisionDocuments" />
                                    <label for="toggleRevisions">Include Revisions</label>
                                </div>
                            </div>
                            <div class="toggle">
                                <input id="toggleArtificial" type="checkbox"
                                       data-bind="checked: includeArtificialDocuments" />
                                <label for="toggleArtificial">Include Artificial Documents</label>
                            </div>
                            <div class="toggle">
                                <input id="toggleArchived" type="checkbox"
                                       data-bind="checked: includeArchivedDocuments" />
                                <label for="toggleArchived">Include Archived Documents</label>
                            </div>
                            <div class="toggle">
                                <input id="toggleConflicts" type="checkbox" data-bind="checked: includeConflicts" />
                                <label for="toggleConflicts">Include Conflicts</label>
                            </div>
                            <div class="toggle">
                                <input id="importTimeSeriesDeletedRanges" type="checkbox" data-bind="checked: includeTimeSeriesDeletedRanges" />
                                <label for="importTimeSeriesDeletedRanges" class="margin-right margin-right-sm">Include Time Series Deleted Ranges</label>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-5">
                        <h4>Cluster Entities:</h4>
                        <div class="margin-left">
                            <div class="toggle">
                                <input id="toggleIndexes" type="checkbox" data-bind="checked: includeIndexes" />
                                <label for="toggleIndexes">Include Indexes</label>
                            </div>
                            <div class="margin-left">
                                <div class="toggle">
                                    <input id="toggleIndexHistory" type="checkbox"
                                           data-bind="checked: databaseModel.includeIndexHistory, enable: includeIndexes" />
                                    <label for="toggleIndexHistory">Include Index History</label>
                                </div>
                                <div class="toggle">
                                    <input id="toggleAnalyzers" type="checkbox" 
                                           data-bind="checked: removeAnalyzers, enable: includeIndexes" />
                                    <label for="toggleAnalyzers">Remove Analyzers</label>
                                </div>
                            </div>
                            <div class="toggle">
                                <input id="toggleIdentities" type="checkbox" data-bind="checked: includeIdentities" />
                                <label for="toggleIdentities">Include Identities</label>
                            </div>
                            <div class="toggle">
                                <input id="toggleCmpXch" type="checkbox" data-bind="checked: includeCompareExchange" />
                                <label for="toggleCmpXch">Include Compare Exchange</label>
                            </div>
                            <div class="toggle">
                                <input id="toggleSubscriptions" type="checkbox" data-bind="checked: includeSubscriptions" />
                                <label for="toggleSubscriptions" class="margin-right margin-right-sm">Include Subscriptions</label>
                            </div>
                            <div class="toggle">
                                <input id="toggleConfiguration" type="checkbox" data-bind="checked: includeDatabaseRecord" />
                                <label for="toggleConfiguration" class="margin-right margin-right-sm">Include Configuration and Ongoing Tasks</label>
                                <button class="btn btn-default btn-sm margin-right margin-right-sm" data-bind="enable: includeDatabaseRecord, click: $root.customizeConfigurationClicked">Customize</button>
                                <small id="js-ongoing-tasks-disabled"><i class="icon-info text-info"></i></small>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 col-sm-6">
                        <div data-bind="validationElement: exportDefinitionHasIncludes">
                            <div class="help-block" data-bind="validationMessage: exportDefinitionHasIncludes"></div>
                        </div>
                    </div>
                </div>
                <hr />
                <div class="row">
                    <div class="col-lg-6">
                        <div class="toggle">
                            <input id="toggleEncryption" type="checkbox" data-bind="checked: encryptOutput" />
                            <label for="toggleEncryption">Encrypt exported file</label>
                        </div>
                    </div>
                </div>
                <div class="row" data-bind="collapse: encryptOutput">
                    <div class="col-sm-12 col-lg-6" data-bind="with: $root.encryptionSection">
                        <div class="margin-left">
                            <div data-bind="compose: $root.setupEncryptionKeyView"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div id="export-advanced" data-bind="collapse: showAdvancedOptions">
                <hr />
                <h3>Advanced</h3>
                <div class="margin-left">
                    <!-- TODO: see issue 8493 ! -->
                    <!--<div class="toggle">
                        <input id="expiredDocuments" type="checkbox" disabled="disabled" data-bind="checked: model.includeExpiredDocuments">
                        <label for="expiredDocuments">Include Expired Documents</label>
                    </div>-->
                    <div class="toggle">
                        <input id="Collections" type="checkbox" data-bind="checked: model.includeAllCollections" />
                        <label for="Collections">Export all collections</label>
                    </div>
                    <div data-bind="visible: !collections().length && !model.includeAllCollections()">
                        No collections available
                    </div>
                    <div id="collapseCollections" data-bind="collapse: !model.includeAllCollections(), visible: collections().length">
                        <div class="border">
                            <div class="row">
                                <div class="col-sm-6">
                                    <h4>Select collections:</h4>
                                </div>
                                <div class="col-sm-6">
                                    <div class="input-group input-group-sm">
                                        <span class="input-group-addon"><span class="glyphicon glyphicon-filter" aria-hidden="true"></span></span>
                                        <input class="form-control" placeholder="Filter" data-bind="textInput: filter" />
                                    </div>
                                </div>
                            </div>
                            <hr/>
                            <div class="row limit-height" data-bind="foreach: filteredCollections">
                                <div class="col-sm-6">
                                    <div class="toggle toggle-info">
                                        <input class="styled" type="checkbox" data-bind="attr: { id: 'collection_' + $index() }, value: $data, checked: $root.model.includedCollections" />
                                        <label data-bind="attr: { for: 'collection_' + $index() }, text: $data">
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <hr/>
                    </div>
                    <div class="form-group">
                        <div class="toggle">
                            <input id="useTransformScript" type="checkbox" data-bind="checked: showTransformScript" />
                            <label for="useTransformScript" class="margin-right margin-right-sm">Use Transform script </label>
                            <a id="scriptPopover" tabindex="0"><small><i class="icon-info text-info"></i></small></a>
                        </div>
                        <div data-bind="collapse: showTransformScript">
                        <pre class="form-control" style="height: 200px;" data-bind="aceEditor: { code: model.transformScript, lang: 'ace/mode/javascript', completer: completer }, validationOptions: { errorsAsTitle: false }, validationElement: model.transformScript">
                        </pre>
                            <div data-bind="validationOptions: { errorsAsTitle: false }, validationElement: model.transformScript">
                                <div class="help-block" data-bind="validationMessage: model.transformScript"></div>
                            </div>
                        </div>
                        <div class="toggle">
                            <input id="skipCorruptedData" type="checkbox" data-bind="checked: model.skipCorruptedData" />
                            <label for="skipCorruptedData" class="margin-right margin-right-sm">Skip Corrupted Data </label>
                            <a id="skipCorruptedDataPopover" tabindex="0"><small><i class="icon-info text-info"></i></small></a>
                        </div>
                        <div data-bind="with: model.databaseModel">
                            <div data-bind="compose: $root.smugglerDatabaseRecordView"></div>
                        </div>
                        <div class="toggle">
                            <input id="isSetMaxReadOpsPerSecond" type="checkbox" data-bind="checked: model.isSetMaxReadOpsPerSecond" />
                            <label for="isSetMaxReadOpsPerSecond" class="margin-right margin-right-sm">Set Max Read Operations Per Second </label>
                        </div>
                        <div data-bind="collapse: model.isSetMaxReadOpsPerSecond">
                            <div class="input-group margin-right">
                                <input id="maxReadOpsPerSecond" type="number" min="1" class="form-control input-border" data-bind="numericInput: model.maxReadOpsPerSecond" placeholder="Max read operations per second" />
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        Compression Algorithm: 
                        <div class="btn-group margin-left-xs">
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                <span data-bind="text: getCompressionAlgorithmLabel(model.compressionAlgorithm())"></span>
                                <span class="caret margin-left margin-left-xs"></span>
                            </button>
                            <ul class="dropdown-menu">
                                <li><a href="#" data-bind="click: model.compressionAlgorithm.bind(model.compressionAlgorithm, null)"><span>Default</span></a></li>
                                <!-- ko foreach: $root.compressionAlgorithms -->
                                <li><a href="#" data-bind="click: $root.model.compressionAlgorithm.bind($root.model.compressionAlgorithm, $data)"><span data-bind="text: $data"></span></a></li>
                                <!-- /ko -->
                            </ul>
                        </div>
                    </div>
                    <div class="flex-horizontal" data-bind="with: $root">
                        <div class="btn-group">
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                <span data-bind="text: getCommandTypeLabel(effectiveCommandType())"></span>
                                <span class="caret margin-left margin-left-xs"></span>
                            </button>
                            <ul class="dropdown-menu" data-bind="foreach: commandTypes">
                                <li><a href="#" data-bind="click: $root.effectiveCommandType.bind($root.effectiveCommandType, $data)"><span data-bind="text: $root.getCommandTypeLabel($data)"></span></a></li>
                            </ul>
                        </div>
                        <div class="flex-grow">
                            <input onClick="this.select();" class="form-control" readonly data-bind="value: effectiveCommand" />
                        </div>
                        <button class="btn btn-default" data-bind="click: copyCommandToClipboard" title="Copy export command to clipboard">
                            <i class="icon-copy-to-clipboard"></i>
                        </button>
                    </div>
                </div>
            </div>
            <hr/>
            <div class="row" data-bind="collapse: model.itemsToWarnAbout">
                <div class="col-sm-12 col-lg-6">
                    <div class="bg-warning text-warning padding padding-xs margin-bottom flex-horizontal">
                        <div class="flex-start"><small><i class="icon-warning"></i></small></div>
                        <div>
                            <small>Note: You are exporting <span data-bind="text: model.itemsToWarnAbout"></span> data without including the Documents.</small><br>
                            <small>The documents will be needed when importing this exported file to another database.</small>
                        </div>
                    </div>
                </div>
            </div>
            <button class="btn btn-default" type="button" data-bind="click: showAdvancedOptions.toggle.bind(showAdvancedOptions)">
                <span data-bind="text: showAdvancedOptions() ? 'Close ' : ''"></span>Advanced
            </button>
            <button class="btn btn-primary" type="submit" data-bind="disable: isExporting, css: { 'btn-spinner': isExporting() }">
                <i class="icon-export"></i> <span>Export Database</span>
            </button>
        </form>
    </div>
</div>
<div class="hidden">
    <form method="post" download target="hidden-form" id="exportDownloadForm">
        <input type="hidden" name="DownloadOptions"/>
    </form>
</div>
</div>
